package com.zwps.biz.domain.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zwps.biz.domain.config.properties.NeteasePhoneCodeMessageConfigProperties;
import com.zwps.biz.domain.extra.netease.NeteasePhoneCodeMessage;
import com.zwps.biz.domain.extra.netease.NeteasePhoneMessageHelper;

/**
 * @author shanwen
 * @description:
 * @date 2023-08-02
 * @ClassName NeteaseMessageService
 */
@Service
public class NeteaseMessageService {

    @Autowired
    private NeteasePhoneCodeMessageConfigProperties config;

    public String sendCodeMessage(String phone) {
        NeteasePhoneMessageHelper helper = new NeteasePhoneMessageHelper(config.getAppKey(), config.getAppSecret(),
                config.getCodeServerUrl(), config.getNonce());
        return helper.sendCode(new NeteasePhoneCodeMessage(config.getCodeTemplateId(), phone, config.getCodeLen()));
    }

    public void sendVerifyCodeMessage(String phone, String code) {
        NeteasePhoneMessageHelper helper = new NeteasePhoneMessageHelper(config.getAppKey(), config.getAppSecret(),
                config.getCodeServerUrl(), config.getNonce());
        helper.verifyCode(phone, code);
    }
}
